package com.unsky.utils.vo;

import java.util.ArrayList;
import java.util.List;

public class ListRetVO<T>  extends RetVO {
	/**
	 * 状态
	 * 0失败 ;1成功
	 */
	private int status;  
	private String msg;// 描述信息
	private List<T> objs;
	private long size;

	public final static int SUCCESS = 1;
	public final static int FAILED = 0;
	public final static String SUCCESS_MSG = "操作成功";
	/**
	 * 用于默认的无返回的数据成功
	 */
	public ListRetVO() {
		this(null);
	}
	/**
	 * 用于默认又返回的成功
	 * @param objs
	 */
	public ListRetVO(List<T> objs) {
		this(SUCCESS, SUCCESS_MSG, objs,objs==null?0:objs.size());
	}

	/**
	 * 用于失败的情况
	 * @param status
	 * @param msg
	 */
	public ListRetVO(int status, String msg) {
		this(status, msg, null, 0);
	}
	/**
	 * 
	 * @param status 状态
	 * @param msg 提示消息
	 * @param objs 返回对象
	 * @param size 数据条数
	 */
	public ListRetVO(int status, String msg, List<T> objs, long size) {
		super();
		this.status = status;
		this.msg = msg;
		this.objs = objs;
		this.size = size;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public List<T> getObjs() {
		return objs;
	}

	public void setObjs(List<T> objs) {
		this.objs = objs;
		setSize(objs.size());
	}

	public long getSize() {
		return size;
	}

	public void setSize(long size) {
		this.size = size;
	}
	/**
	 * 单个添加
	 * @param obj
	 */
	public void add(T obj){
		if(objs==null){
			objs=new ArrayList<>();
		}
		objs.add(obj);
		setSize(objs.size());
	}
	


}
